package com.bsoft.wx.task;

import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * @author hdh
 * @ Data   :Created in 22:36 2023/2/16
 * @ Description 定义线程任务
 * @ Modified By: hdh
 * @ Version : 1.0
 */
@Component
@Scope("prototype")
public class EmailTask implements Serializable {

    @Autowired
    private JavaMailSender javaMailSender;

    @Value("${emos.email.system}")

   private String mailbox;
    @Async
    public void  sendAsync(SimpleMailMessage mailMessage){
        mailMessage.setFrom(mailbox);
        javaMailSender.send(mailMessage);
    }
}
